package com.etoak.common.config;

import com.etoak.common.filter.CrossFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置跨域过滤器
 */
@Configuration
public class CrossFilterConfig {

    @Bean
    public FilterRegistrationBean<CrossFilter> crossFilterFilterRegistrationBean(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        //filter-class 创建过滤器对象
        registrationBean.setFilter(new CrossFilter());

        //url-pattern
        registrationBean.addUrlPatterns("/*");

        //order
        registrationBean.setOrder(1);
        return registrationBean;
    }

}
